How To Create Intrinsic Height Widget Using Flutter Android App

admin_img Posted By Bajarangi soft , Posted On 29-10-2020

A widget that sizes its child to the child's intrinsic height.This class is useful, for example, when unlimited height is available and you would like a child that would otherwise attempt to expand infinitely to instead size itself to a more reasonable height.The constraints that this widget passes to its child will adhere to the parent's constraints, so if the constraints are not large enough to satisfy the child's maximum intrinsic height, then the child will get less height than it otherwise would. Likewise, if the minimum height constraint is larger than the child's maximum intrinsic height, the child will be given more height than it otherwise would.

How To Create Intrinsic Height Widget Using Flutter Android App

Intrinsic Height Widget
Complete Code For Intrinsic Height Widget In Flutter
main.dart

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'APP',
      home: MyHomePage(),
    );
  }
}
class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
          backgroundColor: Colors.deepOrangeAccent,
          title: Text("IntrinsicHeight Widget"
          )),
      body: Center(
        child: IntrinsicHeight(
          child: Padding(
            padding: const EdgeInsets.only(left:50.0),
            child: Row(
              children: [
                Container(
                  height: 100.0,
                  width: 20.0,
                  color: Colors.red,
                  child: Container(color: Colors.deepOrangeAccent),
                ),
                SizedBox(width: 10),
                Container(
                  height: 50.0,
                  width: 20.0,
                  child: Container(color: Colors.lightGreen),
                ),
                SizedBox(width: 10),
                Container(
                  height: 200.0,
                  width: 20.0,
                  child: Container(color: Colors.pink),
                ),
                SizedBox(width: 10),
                Container(
                  height: 40.0,
                  width: 20.0,
                  child: Container(color: Colors.pink),
                ),
                SizedBox(width: 10),
                Container(
                  height: 90.0,
                  width: 40.0,
                  child: Container(color: Colors.indigo,),
                ),
                SizedBox(width: 10),
                Container(
                  height: 350.0,
                  width: 20.0,
                  child: Container(color: Colors.blueGrey,),
                ),
                SizedBox(width: 10),
                Container(
                  height: 30.0,
                  width: 10.0,
                  child: Container(color: Colors.amber),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

Related Post